package com.danjoas.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.danjoas.dao.AutorDao;
import com.danjoas.model.Autor;
import com.danjoas.service.AutorService;

/**
 *
 * @author Dan Joas
 */
@Service("autorService")
public class AutorServiceImpl implements AutorService {

    @Autowired
    AutorDao autorDao;

    public List<Autor> list() {
        return autorDao.list();
    }

    @Transactional
    public Autor getById(Integer id) {
        return autorDao.getById(id);
    }

    @Transactional
    public Autor getByNombre(String nombre) {
        return autorDao.getByNombre(nombre);
    }

    // @PreAuthorize("hasAnyRole('ROLE_USER','ROLE_ADMIN','ROLE_SU')")
    @Transactional
    public void insert(Autor autor) {
        autorDao.insert(autor);
    }

    // @PreAuthorize("hasAnyRole('ROLE_ADMIN','ROLE_SU')")
    @Transactional
    public void update(Autor autor) {
        autorDao.update(autor);
    }

    // @PreAuthorize("hasRole('ROLE_SU')")
    @Transactional
    public void delete(Autor autor) {
        autorDao.delete(autor);
    }
}
